/*
#**************************************************************************
#  openSIS is a student information system for public and non-public 
#  schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
#  openSIS is  web-based, open source, and comes packed with features that 
#  include student demographic info, scheduling, grade book, attendance, 
#  report cards, eligibility, transcripts, parent portal, 
#  student portal and more.   
#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send 
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License  
#  as  published by the Free Software Foundation, version 2 of the License. 
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************** 
*/
namespace calendar
{
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Web;
    using System.Web.SessionState;
    using System.Resources;
    using System.Globalization;
    using System.Collections.Specialized;
    using System.Data;
    
   // using _OSISMainMenuBusinessLayer;
    
   // using System.Web.Routing;


    /// <summary>
    ///    Summary description for Global.
    /// </summary>
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(Object sender, EventArgs e)
        {
            ResourceManager rm = new CCSResourceManager("resources.strings", System.Reflection.Assembly.Load(new System.Reflection.AssemblyName("App_GlobalResources")));


            Application["rm"] = rm;
            Application["_locales"] = System.Configuration.ConfigurationManager.GetSection("locales");
            HttpContext.Current.Cache.Insert("__InvalidateAllPages", DateTime.Now, null,
                                              System.DateTime.MaxValue, System.TimeSpan.Zero,
                                              System.Web.Caching.CacheItemPriority.NotRemovable,
                                              null);

            //RegisterRoutes(RouteTable.Routes);

        }

        protected void Session_Start(Object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(Object sender, EventArgs e)
        {

            if (Application[Request.PhysicalPath] != null)
                Request.ContentEncoding = System.Text.Encoding.GetEncoding(Application[Request.PhysicalPath].ToString());



            //string[] languages = HttpContext.Current.Request.UserLanguages;
            //if (languages[0].ToLower() != null && languages[0].ToLower() != "")
            //{
            //    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(languages[0].ToLower());
            //    System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(languages[0].ToLower());

            //}




        }

        protected void Application_EndRequest(Object sender, EventArgs e)
        {

        }

        protected void Session_End(Object sender, EventArgs e)
        {

        }

        protected void Application_End(Object sender, EventArgs e)
        {
            
        }

        //public static void RegisterRoutes(RouteCollection routes)
        //{

        //    //try
        //    //{


        //    //    routes.Add("DetailInformation", new Route("School/SchoolDetail", new CustomRouteHandler("~/School/SchoolDetails.aspx")));
        //    //    routes.Add("Login", new Route("Login", new CustomRouteHandler("~/login.aspx")));

        //    //    routes.Add("Year", new Route("Calendar/year", new CustomRouteHandler("~/Calendar/year.aspx")));
        //    //    routes.Add("Day", new Route("Calendar/day", new CustomRouteHandler("~/Calendar/day.aspx")));
        //    //    routes.Add("Week", new Route("Calendar/week", new CustomRouteHandler("~/Calendar/week.aspx")));
        //    //    routes.Add("Installation", new Route("Installation/Installation", new CustomRouteHandler("~/Installation/Installation.aspx")));
                


        //    //    MainMenuBL mmBl = new MainMenuBL();

        //    //    DataTable dtMM = mmBl.SearchMainMenuItems();



        //    //    for (int i = 0; i < dtMM.Rows.Count; i++)
        //    //    {
        //    //        string url = dtMM.Rows[i]["url"].ToString();
        //    //        string newurl = "";
        //    //        int count = url.Split("\\".ToCharArray()).Length;

        //    //        for (int j = 0; j < count; j++)
        //    //        {

        //    //            //newurl = url.Split("\\".ToCharArray())[j].ToString();

        //    //            newurl = url;

        //    //            if (newurl.Contains(".aspx"))
        //    //            {
        //    //                newurl = newurl.Split(".".ToCharArray())[0].ToString();
        //    //                newurl = newurl.Replace("\\", "/");
        //    //                break;
        //    //            }

        //    //        }

        //    //        routes.Add(dtMM.Rows[i]["Main_Menu_Header"].ToString(), new Route(newurl, new CustomRouteHandler("~//" + url.Replace("\\", "//"))));

                    

        //    //    }



        //    //    for (int i = 0; i < dtMM.Rows.Count; i++)
        //    //    {
        //    //        mmBl.MMenuHeader = dtMM.Rows[i]["Main_Menu_Header"].ToString();

        //    //        DataTable dtsubmenu = mmBl.SearchMainMenuSubMenuItems();

        //    //        for (int k = 0; k < dtsubmenu.Rows.Count; k++)
        //    //        {

        //    //            string urlsub = dtsubmenu.Rows[k]["Url"].ToString();
        //    //            string newurlsub = "";
        //    //            int countsub = urlsub.Split("\\".ToCharArray()).Length;

                        

        //    //            for (int m = 0; m < countsub; m++)
        //    //            {

        //    //                //newurlsub = urlsub.Split("\\".ToCharArray())[m].ToString();
        //    //                newurlsub = urlsub;
        //    //                if (newurlsub.Contains(".aspx"))
        //    //                {
        //    //                    newurlsub = newurlsub.Split(".".ToCharArray())[0].ToString();
        //    //                    newurlsub = newurlsub.Replace("\\", "/");
        //    //                    break;
        //    //                }

        //    //            }


        //    //            routes.Add(dtsubmenu.Rows[k]["Main_SubMenu_Header"].ToString() + "_" + dtsubmenu.Rows[k]["Main_Menu_ID"].ToString(), new Route(newurlsub, new CustomRouteHandler("~//" + urlsub.Replace("\\", "//"))));

                        

        //    //            mmBl.MSMenuHeader = dtsubmenu.Rows[k]["Main_SubMenu_Header"].ToString();

        //    //            DataTable dtsubmenuchild = mmBl.SearchMainMenuSubMenuChildItems();

        //    //            for (int n = 0; n < dtsubmenuchild.Rows.Count; n++)
        //    //            {
        //    //                string urlsubchild = dtsubmenuchild.Rows[n]["Url"].ToString();
        //    //                string newurlsubchild = "";
        //    //                int countsubchild = urlsubchild.Split("\\".ToCharArray()).Length;

        //    //                for (int m = 0; m < countsub; m++)
        //    //                {

        //    //                    //newurlsubchild = urlsubchild.Split("\\".ToCharArray())[m].ToString();
        //    //                    newurlsubchild = urlsubchild;

        //    //                    if (newurlsubchild.Contains(".aspx"))
        //    //                    {
        //    //                        newurlsubchild = newurlsubchild.Split(".".ToCharArray())[0].ToString();
        //    //                        newurlsubchild = newurlsubchild.Replace("\\", "/");
        //    //                        break;
        //    //                    }

        //    //                }

        //    //                routes.Add(dtsubmenuchild.Rows[n]["Main_SubMenu_Child_Header"].ToString() + "_" + dtsubmenu.Rows[k]["Main_SubMenu_ID"].ToString(), new Route(newurlsubchild, new CustomRouteHandler("~//" + urlsubchild.Replace("\\", "//"))));


                        
                        
        //    //            }



        //    //        }

                    

        //    //    }


               


        //    //}
        //    //catch
        //    //{ 
            
        //    //}
            
        //}
       
        
    }
}
//End Global

